package lab02.test20;

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 用户从键盘输入一行含有数字和字符的字符串
 * 程序仅仅输出字符串中的全部数字字符
 */
public class Test {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入含有数字和字符的字符串：");

        String ch=scanner.next();
        Pattern p;
        Matcher m;
        p=Pattern.compile("\\d+");
        m=p.matcher(ch);

        while(m.find()){
            String str=m.group();
            System.out.print(str+"  ");
        }
    }
}
